package cn.itcast.sys.mapper;

import cn.itcast.annotation.AutoFill;
import cn.itcast.enumeration.OperationType;
import cn.itcast.sys.dto.EmployeeLoginDTO;
import cn.itcast.sys.dto.EmployeePageQueryDTO;
import cn.itcast.sys.pojo.Employee;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface EmployeeMapper {

    @Select("select * from employee where username = #{username}")
    Employee seleteByUsername(EmployeeLoginDTO dto);


    @AutoFill(OperationType.INSERT)
    void insert(Employee employee);

    /**
     * 员工分页查询
     *
     * @param dto
     * @return
     */
    Page<Employee> pageQuery(EmployeePageQueryDTO dto);

    /**
     * 修改
     *
     * @param employee
     */
    @AutoFill(OperationType.UPDATE)
    void update(Employee employee);

    /**
     * 根据id查询员工
     *
     * @param id
     * @return
     */
    Employee getById(Integer id);

    /**
     *
     * @param empId
     * @return
     */
    @Select("select password from employee where id = #{empId}")
    String getPasswordById(Long empId);

    /**
     * 获取所有
     *
     * @return
     */
    @Select("select * from employee")
    List<Employee> getAll();
}
